package com.hdf.etdemo.view.swicthview;

import com.hdf.easytools.base.EasyToolsActivity;
import com.hdf.etdemo.R;
import com.hdf.etdemo.R.id;
import com.hdf.etdemo.R.layout;
import com.hdf.easytools.view.switchview.SegmentView;
import com.hdf.easytools.view.switchview.SwitchButton;
import com.hdf.easytools.view.switchview.SwitchView;
import com.hdf.easytools.view.switchview.SegmentView.OnIndexChangedListener;
import com.hdf.easytools.view.switchview.SwitchButton.OnToggleChanged;
import com.hdf.easytools.view.switchview.SwitchView.OnCheckedChangedListener;

import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;

public class SwicthVActivity extends EasyToolsActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_swicth_v);
		/** 设置标题显示 */
		this.TitleVisib(0, 1, 1, 0, 0);
		/** 绑定标题点击事件 */
		this.TitleClick(0, 1, 0, 0, 0);
		/** 设置标题样式ʽ */
		this.TitleStyle(null, R.drawable.et_back, "分段式", null, 0);
		SegmentView segmentView = (SegmentView) this.findViewById(R.id.segmentView);
		segmentView.setOnIndexChangedListener(new OnIndexChangedListener() {

			@Override
			public void onChanged(SegmentView view, int index) {
				Toast.makeText(SwicthVActivity.this, "segment" + index, Toast.LENGTH_SHORT).show();
			}

		});

		SwitchView switchView = (SwitchView) this.findViewById(R.id.switchView);
		switchView.setOnCheckedChangedListener(new OnCheckedChangedListener() {

			@Override
			public void onChanged(View view, boolean checked) {
				Toast.makeText(SwicthVActivity.this, "switch" + checked, Toast.LENGTH_SHORT).show();
			}

		});

		SwitchButton switchButton = (SwitchButton) this.findViewById(R.id.switchButton);
		switchButton.setOnToggleChanged(new OnToggleChanged() {

			@Override
			public void onToggle(boolean on) {
				Toast.makeText(SwicthVActivity.this, "switchButton" + on, Toast.LENGTH_SHORT).show();
			}

		});
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.left_img:
			finish();
			break;

		default:
			break;
		}
	}

}
